package o;

import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class dte {
    private static dte ˊ;
    private static final Object ˎ = new Object();
    private static boolean ˏ;
    private List<dsh> ॱ = null;

    public static dte ॱ() {
        dte o_dte;
        synchronized (ˎ) {
            if (ˊ == null) {
                ˊ = new dte();
            }
            o_dte = ˊ;
        }
        return o_dte;
    }

    public synchronized void ˋ(List<dsh> list) {
        if (this.ॱ == null) {
            this.ॱ = new ArrayList();
        }
        if (list != null) {
            this.ॱ.clear();
            this.ॱ.addAll(list);
            Logger.ˎ("LastUsedAppDataMgr", "refreshLastUsedAppList: " + this.ॱ.size());
        }
    }

    public synchronized boolean ˎ() {
        return this.ॱ != null;
    }

    public synchronized dsh ॱ(String str) {
        dsh o_dsh;
        if (TextUtils.isEmpty(str)) {
            Logger.ˋ("LastUsedAppDataMgr", "getLastUsedAppInfo, packageName = null");
            o_dsh = new dsh("", 0);
        } else if (this.ॱ == null) {
            Logger.ˋ("LastUsedAppDataMgr", "getLastUsedAppInfo, lastUsedAppInfoList is null, packageName = " + str);
            o_dsh = new dsh(str, 0);
        } else {
            for (dsh o_dsh2 : this.ॱ) {
                if (str.equals(o_dsh2.ˊ())) {
                    break;
                }
            }
            o_dsh2 = new dsh(str, 0);
        }
        return o_dsh2;
    }

    public synchronized void ˏ(String str) {
        if (this.ॱ == null) {
            Logger.ˋ("LastUsedAppDataMgr", "removeLastUsedAppInfo, lastUsedAppInfoList == null");
        } else {
            dsh ॱ = ॱ(str);
            if (this.ॱ.contains(ॱ)) {
                this.ॱ.remove(ॱ);
                Logger.ˎ("LastUsedAppDataMgr", "removeLastUsedAppInfo pkg :" + str);
            }
        }
    }

    public synchronized void ˎ(String str) {
        if (this.ॱ == null) {
            Logger.ˋ("LastUsedAppDataMgr", "the lastUsedAppInfoList is not initial yet. it's useless to add!");
        } else {
            dsh o_dsh;
            Iterator it = this.ॱ.iterator();
            while (it.hasNext()) {
                o_dsh = (dsh) it.next();
                if (o_dsh != null && str.equals(o_dsh.ˊ())) {
                    it.remove();
                }
            }
            o_dsh = new dsh();
            o_dsh.ˏ(str);
            o_dsh.ˎ(System.currentTimeMillis());
            this.ॱ.add(o_dsh);
            Logger.ˎ("LastUsedAppDataMgr", "addNewDownloadAppLastUsedInfo pkg :" + str);
        }
    }

    public static void ˋ() {
        if (ˏ) {
            dtc.ˋ(1);
            ˋ(false);
        }
    }

    public static void ˋ(boolean z) {
        ˏ = z;
    }
}
